package com.kiell.gulimall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @Description:
 * @Created: with IntelliJ IDEA.
 * @author: kiell
 * @createTime: 2024年5月7日10:16:29
 **/

@Configuration
public class MyRedissonConfig {

    /**
     * 所有对Redisson的使用都是通过RedissonClient
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod="shutdown")
    public RedissonClient redissonClient(){
        Config config = new Config();
        //设置单节点模式，设置redis地址。ssl安全连接redission://192.168.56.102:6379
        //redis://192.168.80.31:6379
        //redis://redis.gulimall:6379
        config.useSingleServer().setAddress("redis://redis.gulimall:6379");
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }

}
